package com.mytx.search.config;

import com.alibaba.media.MediaConfiguration;
import com.alibaba.media.upload.UploadTokenClient;
import com.alibaba.media.upload.impl.DefaultUploadTokenClient;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliConfig {

    @Value("${ali.url}")
    private String url;
    @Value("${ali.appKey}")
    private String appKey;
    @Value("${ali.secret}")
    private String secret;


    @Bean
    public TaobaoClient createTaoBaoClient() {

        return new DefaultTaobaoClient(url, appKey, secret);
    }

    @Bean
    public UploadTokenClient createWanTuTokenClient() {
        MediaConfiguration configuration = new MediaConfiguration();
        configuration.setAk(appKey);
        configuration.setSk(secret);
        configuration.setNamespace("mytx");
        return new DefaultUploadTokenClient(configuration);
    }
}
